Skip to content

test: add pooler SELECT 1 microbench; mimics existing e2e pooler - #2035

Merged
jkaczman merged 1 commit into
mainfrom
jk-pooler-microbench
Nov 14, 2026
Merged

jkaczman merged 1 commit into
mainfrom
jk-pooler-microbench

Conversation

@jkaczman

Copy link
Copy Markdown
Contributor

Previously, all of our microbench cases ran via sharded config, which uses the query parser and router for all requests.

Now, this introduces a SELECT 1 microbench case that uses pooler config to emulate what our end-to-end pooler benchmark does. Specifically, this uses simple protocol and the full request variation of microbench (fake in-memory server)

This allows greater visibility into this specific case, so that we can easily flamegraph it to inspect and make targeted optimizations to improve the regular pooler end-to-end bench.

@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.48148% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...dog/src/frontend/client/query_engine/test/bench.rs 80.76% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown
Contributor

Metal bench (arm64) failed. 5 of 517 measures outside bounds.

suite throughput cpu/txn user cycles/txn user instr/txn kernel cycles/txn kernel instr/txn ctx/txn
pooler 19.16 (+0.2% ± 1.5%) 18,161 (-0.6% ± 1.0%) 31,573 (+0.0% ± 0.06%) 30,918 (+0.5% ± 2.5%) 50,976 (-0.2% ± 0.7%)
lb 19.82 (-0.2% ± 1.2%) 18,904 (-0.3% ± 0.5%) 32,485 (+0.0% ± 0.1%) 31,733 (-0.1% ± 2.5%) 52,168 (-0.1% ± 0.3%)
sharding-w2 31.92 (+0.2% ± 2.1%) 42,775 (-0.7% ± 0.9%) 94,875 (+0.0% ± 0.01%) 39,992 (+1.1% ± 3.7%) 53,764 (-0.0% ± 0.07%) 1.55 (+0.0% ± 0.1%)
sharding-w8 241,274 (-0.2% ± 0.9%) 29.55 (+0.2% ± 0.3%) 44,652 (+0.2% ± 0.9%) 50,460 (+0.0% ± 0.08%) 36,920 (+0.2% ± 0.5%) 42,446 (-0.0% ± 0.2%) 0.1686 (+0.1% ± 2.4%)
Counters per txn
suite frontend stall l1i refill backend stall
pooler 7,757 (-1.5% ± 2.9%) 2,688 (-0.6% ± 1.2%)
lb 8,273 (-1.1% ± 1.3%) 2,766 (-0.5% ± 0.5%)
sharding-w2 17,246 (-1.8% ± 2.1%) 4,064 (-0.9% ± 1.1%)
sharding-w8 20,336 (+0.2% ± 4.8%) 4,121 (+0.2% ± 2.0%)
benchmark measure result baseline change bound
full_extended_cached::having_distinct_limit alloc_count 548 539 +1.56% ± 0.68% +0%
full_named_cached::delete_by_key instructions 59,684 58,847 +1.42% ± 0.00% +1%
full_named_cached::having_distinct_limit alloc_count 532 523 +1.73% ± 1.49% +0%
full_named_cached::insert instructions 61,343 59,538 +3.03% ± 0.00% +1%
full_simple::order_limit_offset instructions 194,699 192,430 +1.18% ± 0.00% +1%

Microbench: 499 of 504 measures within bounds.

Hot code per txn
path base head change
pooler 115.0 KB 114.4 KB -0.6 KB
sharding-w2 166.9 KB 167.6 KB +0.8 KB

pooler:

crate base head change
pgdog::frontend::client::query_engine 20.0 KB 20.2 KB +0.2 KB
tokio 18.4 KB 18.2 KB -0.2 KB
pgdog::backend::pool 17.7 KB 17.5 KB -0.2 KB
aws-lc (TLS crypto) 10.5 KB 10.3 KB -0.2 KB
rustls (TLS) 8.3 KB 8.2 KB -0.1 KB
pgdog::frontend (other) 7.7 KB 7.9 KB +0.2 KB
pgdog::backend::server 7.8 KB 7.8 KB +0.1 KB
other 5.9 KB 5.9 KB +0.0 KB
everything else 18.7 KB 18.2 KB -0.4 KB
function head change
pgdog::frontend::client::Client::run::{{closure}} 5.6 KB +0.2 KB
pgdog::frontend::client::query_engine::query::<impl pgdog::frontend::client::query_engine: 5.4 KB +0.1 KB
pgdog::frontend::client::query_engine::QueryEngine::handle::{{closure}} 4.3 KB +0.1 KB
pgdog::frontend::client::query_engine::query::<impl pgdog::frontend::client::query_engine: 3.2 KB +0.0 KB
tokio::runtime::task::raw::poll 3.1 KB -0.2 KB

sharding-w2:

crate base head change
pgdog::frontend::router 29.3 KB 29.3 KB +0.0 KB
pgdog::frontend::client::query_engine 21.1 KB 20.9 KB -0.2 KB
tokio 18.2 KB 18.7 KB +0.4 KB
pgdog::backend::pool 18.0 KB 18.5 KB +0.5 KB
aws-lc (TLS crypto) 13.1 KB 13.2 KB +0.2 KB
other 10.0 KB 9.9 KB -0.1 KB
pgdog::frontend (other) 8.9 KB 8.9 KB +0.0 KB
pgdog::backend::server 7.7 KB 8.2 KB +0.5 KB
everything else 40.6 KB 40.0 KB -0.6 KB
function head change
pgdog::frontend::client::Client::run::{{closure}} 6.4 KB +0.1 KB
pgdog::frontend::client::query_engine::query::<impl pgdog::frontend::client::query_engine: 5.1 KB +0.0 KB
pgdog::frontend::client::query_engine::QueryEngine::handle::{{closure}} 4.0 KB -0.1 KB
tokio::runtime::task::raw::poll 3.2 KB +0.1 KB
pgdog::frontend::router::parser::query::select::<impl pgdog::frontend::router::parser::que 3.2 KB -0.1 KB
lb flamegraph vs 9ba9caf

lb

Open interactive for hover, zoom and search.

lb removed

Open interactive.

microbench flamegraph vs 9ba9caf

microbench

Open interactive for hover, zoom and search.

microbench removed

Open interactive.

pooler flamegraph vs 9ba9caf

pooler

Open interactive for hover, zoom and search.

pooler removed

Open interactive.

sharding-w2 flamegraph vs 9ba9caf

sharding-w2

Open interactive for hover, zoom and search.

sharding-w2 removed

Open interactive.

sharding-w8 flamegraph vs 9ba9caf

sharding-w8

Open interactive for hover, zoom and search.

sharding-w8 removed

Open interactive.

Logs

lb, microbench, pooler, sharding-w2, sharding-w8, verdict.json

Compared 5bb8ba3 with 9ba9caf on m8g.metal-24xl (spot).

@github-actions

Copy link
Copy Markdown
Contributor

Metal bench (x86) passed. All 517 measures within bounds.

suite throughput cpu/txn user cycles/txn user instr/txn kernel cycles/txn kernel instr/txn ctx/txn
pooler 26.02 (+0.1% ± 0.3%) 18,874 (+0.1% ± 0.2%) 32,919 (-0.0% ± 0.1%) 33,694 (+0.1% ± 0.4%) 36,515 (+0.0% ± 0.5%)
lb 26.4 (-0.1% ± 0.4%) 19,405 (+0.0% ± 0.10%) 33,916 (+0.0% ± 0.04%) 33,781 (-0.1% ± 0.7%) 37,200 (+0.1% ± 0.4%)
sharding-w2 41.97 (-0.0% ± 0.7%) 46,934 (+0.2% ± 0.8%) 98,546 (+0.0% ± 0.02%) 38,512 (-0.4% ± 2.1%) 40,134 (+0.0% ± 0.1%) 1.526 (+0.0% ± 0.6%)
sharding-w8 207,724 (+0.2% ± 1.0%) 32.75 (-0.0% ± 0.9%) 45,809 (+0.0% ± 1.2%) 52,861 (-0.0% ± 0.04%) 31,035 (-0.1% ± 0.8%) 32,532 (-0.1% ± 0.1%) 0.1725 (-0.6% ± 1.0%)
Counters per txn
suite frontend stall l1i refill backend stall
pooler 3,640 (+0.2% ± 0.7%) 1,155 (-0.0% ± 1.2%) 37,983 (+0.1% ± 0.6%)
lb 3,755 (-0.1% ± 0.3%) 1,184 (-0.3% ± 0.3%) 38,988 (+0.0% ± 0.2%)
sharding-w2 6,362 (+0.3% ± 1.2%) 1,528 (+0.2% ± 1.5%) 114,376 (+0.3% ± 1.6%)
sharding-w8 3,410 (-0.0% ± 1.3%) 866 (+0.0% ± 0.7%) 176,902 (+0.1% ± 1.7%)

Microbench: all 504 measures within bounds.

Hot code per txn
path base head change
pooler 116.2 KB 115.1 KB -1.1 KB
sharding-w2 170.7 KB 170.3 KB -0.4 KB

pooler:

crate base head change
pgdog::frontend::client::query_engine 22.4 KB 22.3 KB -0.1 KB
tokio 18.6 KB 18.7 KB +0.1 KB
pgdog::backend::pool 18.4 KB 18.1 KB -0.3 KB
pgdog::frontend (other) 9.2 KB 9.3 KB +0.1 KB
aws-lc (TLS crypto) 9.1 KB 8.5 KB -0.6 KB
rustls (TLS) 7.9 KB 7.9 KB -0.1 KB
pgdog::backend::server 7.8 KB 7.9 KB +0.1 KB
other 5.9 KB 5.6 KB -0.4 KB
everything else 16.9 KB 16.8 KB -0.1 KB
function head change
pgdog::frontend::client::Client::run::{{closure}} 7.2 KB +0.2 KB
pgdog::frontend::client::query_engine::query::<impl pgdog::frontend::client::query_engine: 6.6 KB +0.0 KB
pgdog::frontend::client::query_engine::QueryEngine::handle::{{closure}} 4.8 KB -0.2 KB
tokio::runtime::task::raw::poll 3.8 KB +0.1 KB
pgdog::frontend::client::query_engine::query::<impl pgdog::frontend::client::query_engine: 3.6 KB -0.1 KB

sharding-w2:

crate base head change
pgdog::frontend::router 28.6 KB 28.4 KB -0.2 KB
pgdog::frontend::client::query_engine 23.9 KB 23.1 KB -0.8 KB
pgdog::backend::pool 19.2 KB 18.9 KB -0.3 KB
tokio 18.4 KB 18.8 KB +0.4 KB
other 10.8 KB 11.0 KB +0.2 KB
pgdog::frontend (other) 10.7 KB 10.9 KB +0.2 KB
aws-lc (TLS crypto) 10.4 KB 10.8 KB +0.3 KB
pgdog::backend::server 8.2 KB 8.5 KB +0.2 KB
everything else 40.4 KB 39.9 KB -0.5 KB
function head change
pgdog::frontend::client::Client::run::{{closure}} 8.4 KB +0.2 KB
pgdog::frontend::client::query_engine::query::<impl pgdog::frontend::client::query_engine: 6.5 KB -0.1 KB
pgdog::frontend::client::query_engine::QueryEngine::handle::{{closure}} 4.5 KB -0.2 KB
pgdog::frontend::router::parser::query::select::<impl pgdog::frontend::router::parser::que 4.2 KB +0.1 KB
tokio::runtime::task::raw::poll 4.0 KB +0.2 KB
lb flamegraph vs 9ba9caf

lb

Open interactive for hover, zoom and search.

lb removed

Open interactive.

microbench flamegraph vs 9ba9caf

microbench

Open interactive for hover, zoom and search.

microbench removed

Open interactive.

pooler flamegraph vs 9ba9caf

pooler

Open interactive for hover, zoom and search.

pooler removed

Open interactive.

sharding-w2 flamegraph vs 9ba9caf

sharding-w2

Open interactive for hover, zoom and search.

sharding-w2 removed

Open interactive.

sharding-w8 flamegraph vs 9ba9caf

sharding-w8

Open interactive for hover, zoom and search.

sharding-w8 removed

Open interactive.

Logs

lb, microbench, pooler, sharding-w2, sharding-w8, verdict.json

Compared 5bb8ba3 with 9ba9caf on m7i.metal-48xl (spot).

@jkaczman
jkaczman force-pushed the jk-pooler-microbench branch from 5bb8ba3 to 3ec9b78 Compare November 14, 2026 03:50
@jkaczman
jkaczman merged commit b5cfc26 into main Nov 14, 2026
13 checks passed
@jkaczman
jkaczman deleted the jk-pooler-microbench branch November 14, 2026 03:51
jkaczman added a commit that referenced this pull request Nov 14, 2026
…SERT, etc (#2036)

Previously, with `query_parser` set to auto or session_control, we were
running the session control regex on all queries to look for SET, BEGIN,
COMMIT, etc. This includes queries such as SELECT 1. In the pooler
microbench flamegraph (#2035), the check was a pretty substantial amount
(see below):

<img width="1440" height="672" alt="Screenshot 2026-11-13 at 2 23 54 PM"
src="https://github.com/user-attachments/assets/75979eef-1020-47fc-a440-8f4036cdfa3e"
/>

Now, if the query starts with SELECT, INSERT, UPDATE, DELETE or WITH, we
return early and skip the expensive regex call.

How can we do this? All of the session control patterns occur at the
very start of the query text (**when there's no whitespace / comment
present**); i.e., if we have a query that starts with a keyword like
`SELECT`, which isn't in the `CMD_BASE` keywords, there's no point in
trying to match with `CMD_RE`.

`session_control_and_locks` behavior not changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant